<template>
  <div class="app-container">
    <!-- 查询项-->
    <Header ref="showSearch" :queryParams.sync="queryParams" :isounit.sync="isounit" :headerForm="headerForm"></Header>
    <!-- 工具栏 -->
    <tr-tools  :upload.sync="upload" :query-params="queryParams" :multiple="multiple" :single="single" @getList="getList" @getSearch="getSearch" @addOrEit="showForm($event)" :ids ="ids" :addOrEit.sync="addOrEit"></tr-tools>
    <!-- 运输单位类型列表-->
    <Table   :query-params = "queryParams"  @addOrEit="showTable($event)" :get-list="getList" :queryParams.sync="queryParams"  ref="trTable" :multiple.sync="multiple" :single.sync="single" :ids.sync ="ids"></Table>
    <!-- 添加或修改角色配置对话框 -->
    <add-or-edit ref="addOrEdit" :form ="addOrEit.form" @forms="forms($event)" :isounit.sync="isounit" :open="addOrEit.open"  :title="addOrEit.title" :form.sync ="addOrEit.form" :open.sync ="addOrEit.open" @:open ="openFun"  @getList="getList" :addOrEditForm="addOrEditForm"></add-or-edit>
    <!-- 运输单位类型查询列表 -->
<!--    <show-list :isounitTitle="isounitTitle" :isounitOpen = "isounitOpen"></show-list>-->
    <show-list :isounit = "isounit"  :addOrEit.sync="addOrEit"  :isounit.sync="isounit"   @header="headerFun($event)" @addOrEdit="addOrEditFun($event)"></show-list>
    <!-- 导出 -->
    <upload :upload="upload"></upload>
  </div>
</template>

<script>
  import { listTransport,listIsoUnit,getTransport,delTransport,addAndUpdateTransport,importTemplate,exportTransport,addTransport,updateTransport } from "@/api/erp/transport/transport";
  import Header from '../../../components/erp/transport/header'
  import Table from '../../../components/erp/transport/table'
  import TrTools from '../../../components/erp/transport/trTools'
  import AddOrEdit from '../../../components/erp/transport/addOrEdit'
  import ShowList from '../../../components/erp/transport/showList'
  import Upload from '../../../components/erp/transport/upload'
  export default {
    name: 'indexComponents',
    components: { Upload, ShowList, AddOrEdit, TrTools, Table, Header },
    data() {
      return {
        upload:{},
        headerForm:{
          unitCode:undefined,
          flag:true
        },
        addOrEditForm:{
          unitCode:undefined,
          flag:true
        },
        selectCode:{},
        isounit:{},
        //
        isounitTitle:"",
        isounitOpen:false,
        ids:[],
        //是否刷新列表
        getListStr:false,
        // 是否显示弹出层
        open: false,
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        //表格数据
        transportList:[],
        // 状态数据字典
        statusOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          transportUnitTypeId: undefined,
          description: undefined,
          weightCapacity: undefined,
          uomForWeight: undefined,
          volumeCapacity: undefined,
          uomForVolume: undefined
        },
        addOrEit:{
          open :false,
          // 弹出层标题
          title: "",
          form: {},
        }
      }
    },
    watch:{
      queryParams(val){
        console.info(val)
        // this.addOrEit.open=val;
      },
      // form(val){
      //   this.addOrEit.form=val;
      // }
    },
    created() {
      this.getDicts("sys_normal_disable").then(response => {
        this.statusOptions = response.data;
      });
    },
    methods: {
      headerFun(data){
        console.info('showList传回主页的参数')
        console.info(data)
          this.headerForm.flag = data.flag
          this.headerForm.unitCode = data.unitCode

      },
      addOrEditFun(data){
        console.info('addOrEdit传回主页的参数')
        console.info(data)
        this.addOrEditForm.flag = data.flag
        this.addOrEditForm.unitCode = data.unitCode
      },
      formFun(data){
        this.addOrEit.form = data;
      },
      openFun(data){
        console.info(data)
        this.addOrEit.open = data;
      },
      getSearch(data){
        this.$refs.showSearch.showSearch = data;
      },
      getList(data){
        this.$refs.trTable.getListStr = data;
      },
      showTable(data){
        this.addOrEit.title=data.title;
        this.addOrEit.form=data.form;
        this.addOrEit.open=data.open;
      },
      showForm(data){
        console.log("888888888");
        console.log(data);

        this.addOrEit.title=data.title;
        this.addOrEit.open=data.open;
      },
      forms(data){
        this.$refs.addOrEdit.form.uomForWeight=data
        // this.addOrEit.form=data;
        // console.info(data)
        // debugger
        // if(val.type=="addOrEdit"){
        //   this.forms=this.form
        //   console.info(this.form)
        //   if(val.flag){
        //     this.form.uomForWeight=this.selectCode.unitCode
        //     this.$emit("forms", {uomForWeight:this.selectCode.unitCode});
        //   }else{
        //     this.form.uomForVolume=this.selectCode.unitCode
        //     this.$emit("forms",{uomForVolume:this.selectCode.unitCode});
        //   }
        // }
      }
    }
  }
</script>

<style scoped>

</style>
